package leetCode.tree;

import leetCode.TreeNode;

/**
 * 对称树
 */
public class SymmetricBinaryTree {
    public boolean isSymmetric(TreeNode root) {
        return check(root, root);
    }

    public boolean check(TreeNode left, TreeNode right){
        if (left == null && right == null ) return true;
        if (left.val != right.val || left == null || right == null) return false;
        return left.val == right.val && check(left.left, right.right) && check(left.right, right.left);
    }
}
